/**
 * 
 */
package habitcoach.core.habit;

import habitcoach.core.SystemEnvironment;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import test.mock.MockEnvironment;
import util.Constants;

/**
 * @author Coddy created on 2010-4-24
 * 
 */
public class HabitFactoryTest
{
	HabitFactory instance;

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#setUp()
	 */
	@Before
	public void setUp() throws Exception
	{
		instance = HabitFactory.getInstance();
	}

	/**
	 * Test method for {@link habitcoach.core.habit.HabitFactory#getInstance()}.
	 */
	@Test
	public void testGetInstance()
	{
		HabitFactory hFactory = HabitFactory.getInstance();
		Assert.assertEquals(instance, hFactory);
	}

	/**
	 * Test method for
	 * {@link habitcoach.core.habit.HabitFactory#getInstance(habitcoach.core.Environmental)}
	 * .
	 */
	@Test
	public void testGetInstanceEnvironmental()
	{
		HabitFactory hFactory = HabitFactory.getInstance(new MockEnvironment());
		Assert.assertTrue(HabitFactory.getEnv() instanceof MockEnvironment);
	}

	/**
	 * Test method for
	 * {@link habitcoach.core.habit.HabitFactory#createHabit(java.lang.String)}.
	 */
	@Test
	public void testCreateHabitString()
	{
		Habit hb = instance.createHabit(null, null, "Test");
		Assert.assertEquals("Test", hb.getQuestion());

	}

	/**
	 * Test method for {@link habitcoach.core.habit.HabitFactory#createHabit()}.
	 */
	@Test
	public void testCreateHabit()
	{
		Habit hb = instance.createHabit();
		Assert.assertEquals(Constants.DEFAULT_DAILY_QUESTION, hb.getQuestion());

	}

	/**
	 * Test method for {@link habitcoach.core.habit.HabitFactory#getEnv()}.
	 */
	@Test
	public void testGetEnv()
	{
		Assert.assertTrue(HabitFactory.getEnv() instanceof SystemEnvironment);
	}
}
